class Collection < ActiveRecord::Base
  belongs_to :activity
  
  belongs_to :user,:foreign_key => :collected_by

  validates_presence_of :amount,:activity_id,:currency
  validates_presence_of :currency_rate,:if=>:project_currency_not_tl,:message => 'is required for USD or EURO projects'
  validates_numericality_of :amount
  validates_numericality_of :currency_rate, :if=>:project_currency_not_tl

  #is project in different currency than TL?
  def project_currency_not_tl
    activity.project.is_foreign_currency
  end
  
end

